﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

namespace AIC_PN
{
    public partial class FormSearchDonVi : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            BindDataToRepeater("");
        }

        protected void BindDataToRepeater(string Search)
        {
            List<SqlParameter> arrParams = new List<SqlParameter>();
            arrParams.Add(SqlHelper.CreateParameterObject("@parentID", SqlDbType.NVarChar, ParameterDirection.Input, Session["userdonvi"]));
            arrParams.Add(SqlHelper.CreateParameterObject("@Search", SqlDbType.NVarChar, ParameterDirection.Input, Search));
            DataTable dt = SqlHelper.ExecuteDataTable(CommandType.Text, "SELECT ID,TenDV FROM tblDonVi WHERE (parentID LIKE @parentID+'%'OR ParentID LIKE+'%;'+@parentID+'%') AND (TenDV LIKE '%'+@Search+'%' OR @Search='')", arrParams);
            rptDonVi.DataSource = dt;
            rptDonVi.DataBind();
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            BindDataToRepeater(txtSearch.Text);
        }
    }
}
